package operation;

import Book.Book;
import Book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-05-23
 * Time:21:28
 */
public class ReturnOperation implements IOperation{

    @Override
    public void work(Booklist booklist) {
        System.out.println("归还图书");
        System.out.println("请输入需要归还的图书:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.next();
        int ret = booklist.getUsedSize();
        for (int i = 0; i < ret; i++) {
            if (name.equals(booklist.getBooks(i).getName())){
                booklist.getBooks(i).setBorrowed(false);
                System.out.println("归还成功！");
                return;
            }
        }
        System.out.println("该书以及归还或不为本书屋的书！");
    }
}
